<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--

  descript

  @author 94765 2021/11/13 18
3 
--><html>
  <head>
    <title>xxx学生管理</title>
    <style>
        table{
          width: 700px;
          margin: 100px auto;
          border: 1px solid black;
        }

        th{
          border: 1px solid black;
          text-align: center;
        }

        td{
          border: 1px solid black;
          text-align: center;
        }
        form{
            margin: 0;
        }
        input{
            margin: 5px auto;
        }
    </style>
      <script>
            //实现翻页查询
            function goPage(pageNum) {
                location.href = "/student/page?pageNum=" + pageNum;
            }
      </script>
  </head>
  <body>

      <table cellspacing="0" cellpadding="0">
          <caption><h2>xxx学生管理</h2></caption>
          <thead>
              <tr>
                <th colspan="6">
                  <form action="/student/page?sname=${sname}&sage=${sage}" method="get">
                      姓名：<input type="text" name="sname" value="${sname}">
                      年龄：<input type="text" name="sage" value="${sage}">
                      <input type="submit" value="查询">
                  </form>
                </th>
                <th >
                    <button id="btn-add">添加</button>
                    <a href="online.jsp">在线用户</a>
                </th>
              </tr>
          <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>地址</th>
            <th>备注</th>
            <th colspan="2">操作</th>
          </tr>
          </thead>
        <tbody>
            <c:forEach var="student" items="${page.list}" varStatus="sta">
                <tr>
                    <td>
                        <c:if test="${page.pageNum >= 1}">
                            ${sta.count + (page.pageNum - 1) * page.pageSize}
                        </c:if>
                    </td>
                    <td>${student.sname}</td>
                    <td>
                        <c:if test="${student.gender == '0'}">女</c:if>
                        <c:if test="${student.gender == '1'}">男</c:if>
                    </td>
                    <td>${student.sage}</td>
                    <td>${student.address}</td>
                    <td>${student.remark}</td>
                    <td><a href="http://localhost:8080/student/editUI?id=${student.id}">编辑</a>
                        <a href="http://localhost:8080/student/remove?id=${student.id}&pageNum=${page.pageNum}">删除</a></td>
<%--                        <a href="javascript:deleteById(${student.id})">删除</a>--%>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="7">
                    总记录数:${page.total}
                    总页数:${page.pages}
                    每页显示最大记录数:${page.pageSize}
                    <a href="javascript:goPage(1)">首页</a>
                    <c:if test="${page.pageNum > 1}">
                        <a href="javascript:goPage(${page.pageNum - 1})">上一页</a>
                    </c:if>
                    ${page.pageNum}
                    <c:if test="${page.pageNum < page.pages}">
                        <a href="javascript:goPage(${page.pageNum + 1})">下一页</a>
                    </c:if>
                    <a href="javascript:goPage(${page.pages})">末页</a>
                </td>
            </tr>
        </tbody>
      </table>

  <script>
      document.getElementById("btn-add").onclick = function () {
            window.location.href = "http://localhost:8080/student/addUI";
      }
  </script>
  </body>
</html>
